Table of Contents Previous Section

WebScript Language Summary

This section summarizes the WebScript language.

Reserved Words

WebScript includes the following reserved words:

if
else
for
while
id
break
continue
nil
YES/NO
persistent
session
action

Statements

WebScript supports the following statements:

if
else
for
while
break
continue
return
In WebScript these statements behave as they do in the C language.

Arithmetic Operators

WebScript supports the arithmetic operators +, - , /, *, and %. The rules of precedence in WebScript are the same as those for the C language. You can use these operators in compound statements such as:

b = (1.0 + 3.23546) + (((1.0 * 2.3445) + 0.45 + 0.65) - 3.2);

Logical Operators

WebScript supports the negation (!), AND (&&), and OR (||) logical operators. You can use these operators as you would in the C language, for example:

if ( !(!a || a && !i) || (a && b) && (c || !a && (b+3)) ) i = 0;

Relational Operators

WebScript supports the relational operators <, <=, >, >=, ==, and !=. 

In WebScript these operators behave as they do in C.

Increment and Decrement Operators

WebScript supports the ++ and -- operators. These operators behave as they do in the C language, for example:

// Use myVar as the value of the expression and then increment myVar
myVar++;

// Increment myVar and then use its value as the value of the expression
++myVar;

id

WebScript only supports one data type: objects (ids). The id type is defined as a pointer to an object---in reality, a pointer to the object's data (its instance variables). Like a C function or an array, an object is identified by its address. All objects, regardless of their instance variables or methods, are of type id.

self

In WebScript, self is available in every method. It refers to the object (either the WOApplication object or the WOWebScriptComponentController object) associated with a script. When you send a message to self, you're telling the object associated with the script to perform a method that's implemented in the script.

persistent

The persistent keyword is used in a component script to identify a variable whose state is maintained for the duration of the current session (as opposed to transaction variables, which cease to exist at the end of a transaction).

session

The session keyword is used in an application script to identify a variable whose state is maintained for the duration of an application, and of which every session has its own version (as opposed to global variables, which has the same value in all sessions).

action

The action keyword is used in a child component script to identify a WOAction object that the parent component associates with a method.

WOApp Global Variable

WOApp is a global variable that provides a shorthand for the following statement:

[WOApplication sharedObject];

This statement returns the single WOApplication object that is accessed by all users of an application.

Table of Contents Next Section